package com.oocl.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.oocl.exception.MyException;
import com.oocl.service.CustomerService;
import com.oocl.service.impl.CustomerServiceFactory;
import com.oocl.service.impl.ServiceFactory;


public class RemoveServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String idStr = request.getParameter("id");
		int id = Integer.parseInt(idStr);
		CustomerServiceFactory factory =null;
		try {
			factory = (CustomerServiceFactory) ServiceFactory.getServiceFactory(CustomerServiceFactory.CUSTOMER);
			CustomerService cSer = factory.getService();
			boolean result  = cSer.remove(id);
		} catch (MyException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		response.sendRedirect("list");
	}

}
